export default {
  data() {
    return {
      pageLoading: false,
      list: [],
      status: 'loadmore',//懒加载
      activation: '',
      id: '',
      storeId: '',
      listIndex: 1,
      firstLoading: false // 第一次加载
    }
  },
  computed: {

  },
  onReachBottom(){
    if (this.status === 'nomore') return false
	  this.GetFansListDataList()
  },
  created() {
    this.storeId  = this.$store.state.userInfoDetail.store.storeId
    this.GetFansListDataList()
  },

  methods: {
    // 加载前、中、后
    moreStatus(status) {
		  this.status = status
    },
    //粉丝列表
    async GetFansListDataList() {
      this.status = 'loading'
      try {
        // uni.showLoading()

        let data = {
          'PageIndex': this.listIndex,
          'PageSize': 10,
          'Store_Id': this.storeId
        }
        const res = await this.$api.busFollow.GetFansListDataList(data)
        this.list = [...this.list, ...res.data.list]
        this.$nextTick(() => {
				  this.pageLoading = true
        })
        this.firstLoading = this.list.length === 0
        this.moreStatus(res.data.list.length >= 10 ? 'loadmore' : 'nomore')
        if (res.data.list.length !== 0) {
          this.listIndex += 1 // 当前页加1
        }
      } catch (e) {
        console.log(e)
      }
      // uni.hideLoading()
    },

    // 收藏/取消收藏
    async collect(item) {
      try{
        let data = {
          store_id: item.store_Id,
          fans_store_id: this.storeId,
          state: item.follow === 0
        }
        const res = await this.$api.store.UpdateState(data)
        this.list = []
        this.listIndex = 1
        this.GetFansListDataList()
      } catch (e) {
        //TODO handle the exception
      }
    },
  }
}
